
package com.almm.web.common;

import lombok.Data;
import java.io.Serializable;


@Data
public class ResponseResult<T> implements Serializable {
    static final String DEFAULT_OK_MSG = "OK";
    static final String DEFAULT_WARN_MSG = "WARN";
    static final String DEFAULT_ERROR_MSG = "ERROR";
    static final int OK_CODE = 200;
    static final int WARN_CODE = 400;
    static final int ERROR_CODE = 500;

    private Boolean result = true;

    private Integer code = 200;

    private String msg = "";

    private T data = null;


    private ResponseResult(Boolean result, Integer code, String msg, T data) {
        this.result = result;
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static <T> ResponseResult<T> ok() {
        return new ResponseResult(true, 200, "OK", (Object)null);
    }

    public static <T> ResponseResult<T> ok(String msg) {
        return new ResponseResult(true, 200, msg, (Object)null);
    }

    public static <T> ResponseResult<T> ok(T data) {
        return new ResponseResult(true, 200, "OK", data);
    }

    public static <T> ResponseResult<T> ok(String msg, T data) {
        return new ResponseResult(true, 200, msg, data);
    }

    public static <T> ResponseResult<T> warn() {
        return new ResponseResult(false, 400, "WARN", (Object)null);
    }

    public static <T> ResponseResult<T> warn(String msg) {
        return new ResponseResult(false, 400, msg, (Object)null);
    }

    public static <T> ResponseResult<T> warn(Integer code) {
        return new ResponseResult(false, code, "WARN", (Object)null);
    }

    public static <T> ResponseResult<T> warn(Integer code, String msg) {
        return new ResponseResult(false, code, msg, (Object)null);
    }

    public static <T> ResponseResult<T> warn(String msg, T data) {
        return new ResponseResult(false, 400, msg, data);
    }

    public static <T> ResponseResult<T> warn(Integer code, String msg, T data) {
        return new ResponseResult<>(false, code, msg, data);
    }

    public static <T> ResponseResult<T> error() {
        return new ResponseResult(false, 500, "ERROR", (Object)null);
    }

    public static <T> ResponseResult<T> error(String msg) {
        return new ResponseResult(false, 500, msg, (Object)null);
    }

    public static <T> ResponseResult error(Integer code) {
        return new ResponseResult(false, code, "ERROR", (Object)null);
    }

    public static <T> ResponseResult<T> error(Integer code, String msg) {
        return new ResponseResult(false, code, msg, (Object)null);
    }

    public static <T> ResponseResult<T> error(String msg, T data) {
        return new ResponseResult(false, 500, msg, data);
    }

    public static <T> ResponseResult<T> error(Integer code, String msg, T data) {
        return new ResponseResult(false, code, msg, data);
    }
}
